#include "fxcc/yml/Serializer.h"
#include "fxcc/core/graph/common/TextureMaps.h"

using namespace fxcc::yml;
using namespace fxcc::graph::common;

template<>
void Serializer::Encode<Texture2DMap>(YAML::Node& node, const Texture2DMap& inst)
{
	SetVariable<MetaMapIndex>(node, "m_Index", inst.m_Index);
}

template<>
bool Serializer::Decode<Texture2DMap>(const YAML::Node& node,  Texture2DMap& inst)
{
	GetVariable<MetaMapIndex>(node, "m_Index", inst.m_Index);
	return true;
}

template<>
void Serializer::Encode<Texture2DArrayMap>(YAML::Node& node, const Texture2DArrayMap& inst)
{
	SetVariable<MetaMapIndex>(node, "m_Index", inst.m_Index);
}

template<>
bool Serializer::Decode<Texture2DArrayMap>(const YAML::Node& node, Texture2DArrayMap& inst)
{
	GetVariable<MetaMapIndex>(node, "m_Index", inst.m_Index);
	return true;
}


template<>
void Serializer::Encode<TextureCubeMap>(YAML::Node& node, const TextureCubeMap& inst)
{
	SetVariable<MetaMapIndex>(node, "m_Index", inst.m_Index);
}

template<>
bool Serializer::Decode<TextureCubeMap>(const YAML::Node& node, TextureCubeMap& inst)
{
	GetVariable<MetaMapIndex>(node, "m_Index", inst.m_Index);
	return true;
}

template<>
void Serializer::Encode<TextureCubeArrayMap>(YAML::Node& node, const TextureCubeArrayMap& inst)
{
	SetVariable<MetaMapIndex>(node, "m_Index", inst.m_Index);
}

template<>
bool Serializer::Decode<TextureCubeArrayMap>(const YAML::Node& node, TextureCubeArrayMap& inst)
{
	GetVariable<MetaMapIndex>(node, "m_Index", inst.m_Index);
	return true;
}

template<>
void Serializer::Encode<Texture3DMap>(YAML::Node& node, const Texture3DMap& inst)
{
	SetVariable<MetaMapIndex>(node, "m_Index", inst.m_Index);
}

template<>
bool Serializer::Decode<Texture3DMap>(const YAML::Node& node, Texture3DMap& inst)
{
	GetVariable<MetaMapIndex>(node, "m_Index", inst.m_Index);
	return true;
}

template<>
void Serializer::Encode<BRDFTextureMap>(YAML::Node& node, const BRDFTextureMap& inst)
{
	SetVariable<MetaMapIndex>(node, "m_Index", inst.m_Index);
}

template<>
bool Serializer::Decode<BRDFTextureMap>(const YAML::Node& node, BRDFTextureMap& inst)
{
	GetVariable<MetaMapIndex>(node, "m_Index", inst.m_Index);
	return true;
}


template<>
void Serializer::Encode<IrradianceTextureMap>(YAML::Node& node, const IrradianceTextureMap& inst)
{
	SetVariable<MetaMapIndex>(node, "m_Index", inst.m_Index);
}

template<>
bool Serializer::Decode<IrradianceTextureMap>(const YAML::Node& node, IrradianceTextureMap& inst)
{
	GetVariable<MetaMapIndex>(node, "m_Index", inst.m_Index);
	return true;
}

template<>
void Serializer::Encode<PrefilterTextureMap>(YAML::Node& node, const PrefilterTextureMap& inst)
{
	SetVariable<MetaMapIndex>(node, "m_Index", inst.m_Index);
}

template<>
bool Serializer::Decode<PrefilterTextureMap>(const YAML::Node& node, PrefilterTextureMap& inst)
{
	GetVariable<MetaMapIndex>(node, "m_Index", inst.m_Index);
	return true;
}

template<>
void Serializer::Encode<TextureMaps>(YAML::Node& node, const TextureMaps& inst)
{
	Encode<fxcc::Base>(node, inst);
	SetVariable<int>(node,"m_GlslStartIndex", inst.m_GlslStartIndex);
	SetMapVariable<Texture2DMap>(node, "m_Texture2Ds", inst.m_Texture2Ds);
	SetMapVariable<Texture3DMap>(node, "m_Texture3Ds", inst.m_Texture3Ds);
	SetMapVariable<Texture2DArrayMap>(node, "m_Texture2DArrays", inst.m_Texture2DArrays);
	SetMapVariable<TextureCubeMap>(node, "m_TextureCubes", inst.m_TextureCubes);
	SetMapVariable<TextureCubeArrayMap>(node, "m_TextureCubeArrays", inst.m_TextureCubeArrays);

}


template<>
bool Serializer::Decode<TextureMaps>(const YAML::Node& node, TextureMaps& inst)
{
	Decode<fxcc::Base>(node, inst);
	GetVariable<int>(node, "m_GlslStartIndex", inst.m_GlslStartIndex);
	GetMapVariable<Texture2DMap>(node, "m_Texture2Ds", inst.m_Texture2Ds);
	GetMapVariable<Texture3DMap>(node, "m_Texture3Ds", inst.m_Texture3Ds);
	GetMapVariable<Texture2DArrayMap>(node, "m_Texture2DArrays", inst.m_Texture2DArrays);
	GetMapVariable<TextureCubeMap>(node, "m_TextureCubes", inst.m_TextureCubes);
	GetMapVariable<TextureCubeArrayMap>(node, "m_TextureCubeArrays", inst.m_TextureCubeArrays);
	return true;
}
